﻿#include "addstuffwindow.h"
#include "ui_addstuffwindow.h"

addStuffWindow::addStuffWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::addStuffWindow)
{
    ui->setupUi(this);
    ui->sureBtn->setStyleSheet("QPushButton#sureBtn{border-image: url(:/pic/yes.png);}"
                                 "QPushButton#sureBtn:hover{border-image: url(:/pic/yes2.png);}"
                                 "QPushButton#sureBtn:pressed{border-image: url(:/pic/yes3.png);}");
    ui->cancelBtn->setStyleSheet("QPushButton#cancelBtn{border-image: url(:/pic/X.png);}"
                                 "QPushButton#cancelBtn:hover{border-image: url(:/pic/X2.png);}"
                                 "QPushButton#cancelBtn:pressed{border-image: url(:/pic/X3.png);}");
}

addStuffWindow::~addStuffWindow()
{
    delete ui;
}

void addStuffWindow::getSure(const int& index, const int& row)
{
    this->rowIndexSure = row;
    this->index = index;
}

void addStuffWindow::getCancel(const int& index, const int& row)
{
    this->rowIndexCancel = row;
    this->index = index;
}

void addStuffWindow::getGoodSure(const int &index, const int &row)
{
    this->rowIndexSureGood = row;
    this->index = index;
}

void addStuffWindow::getGoodCancel(const int &index, const int &row)
{
    this->rowIndexCancelGood = row;
    this->index = index;
}

void addStuffWindow::on_sureBtn_clicked()
{

//    qDebug() << "确定增加一行";
//    MainWindow* mw = new MainWindow;
//    connect(this, &addStuffWindow::sendSure, mw, &MainWindow::getSure);
    if(this->index == 0)
        emit sendSure(rowIndexSure);
    else if(this->index == 1)
        emit sendGoodSure(rowIndexSureGood);

//    disconnect(this, &addStuffWindow::sendSure, mw, &MainWindow::getSure);
}

void addStuffWindow::on_cancelBtn_clicked()
{

//    MainWindow* mw = new MainWindow;
//    connect(this, &addStuffWindow::sendCancel, mw, &MainWindow::getCancel);
    if(this->index == 0)
        emit sendCancel(rowIndexCancel);
    else if(this->index == 1)
        emit sendGoodCancel(rowIndexCancelGood);
//    disconnect(this, &addStuffWindow::sendCancel, mw, &MainWindow::getCancel);
}
